import { Component, Input, EventEmitter, Output } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-pink',
  templateUrl: './pink.component.html',
  styleUrls: ['./pink.component.css'],
})
export class PinkComponent {
  id: number = 0;
  // ActivatedRoute当前激活的路由相当于route
  constructor(private route: ActivatedRoute) {}

  ngOnInit() {
    // 获取当前路由
    console.log(this.route.params);
    // 返回Observable对象
    this.route.params.subscribe((res) => {
      console.log(res);
      this.id = res['id'];
    });
  }
}
